﻿namespace Attacher
{
	using System.Windows;

	internal class AttacherIconFactory : IAttacherIconFactory
	{
		#region Attributes

		private readonly IMainWindowViewModelFactory mainWindowViewModelFactory;
		private readonly IMainWindowViewModelInitializer mainWindowViewModelInitializer;

		#endregion

		#region Public Methods

		public AttacherIconFactory(IMainWindowViewModelFactory mainWindowViewModelFactory, IMainWindowViewModelInitializer mainWindowViewModelInitializer)
		{
			ParameterChecker.IsNotNull(mainWindowViewModelFactory, "mainWindowViewModelFactory");
			ParameterChecker.IsNotNull(mainWindowViewModelInitializer, "mainWindowViewModelInitializer");

			this.mainWindowViewModelFactory = mainWindowViewModelFactory;
			this.mainWindowViewModelInitializer = mainWindowViewModelInitializer;
		}

		public MainWindow Create()
		{
			MainWindow mainWindow = new MainWindow();

			MainWindowViewModel mainWindowViewModel = this.mainWindowViewModelFactory.Create();
			this.mainWindowViewModelInitializer.Initialize(mainWindowViewModel);

			mainWindow.DataContext = mainWindowViewModel;
			mainWindow.WindowState = WindowState.Minimized;
			mainWindow.Visibility = Visibility.Hidden;

			return mainWindow;
		}

		#endregion
	}
}
